#include "xmpp_io.h"
#include "../../polarssl/inc/ssl.h"
#include "vmlog.h"


extern void write_log_debug(char* buffer, int len);
int
xmpp_send_d (struct xmpp_account *serv, iks *x)
{
	return xmpp_send_raw_d (serv, iks_string (iks_stack (x), x));	
}

int 
xmpp_send_raw_d (struct xmpp_account *serv, char *xml_str)
{
	int xml_len = iks_strlen(xml_str);
	int ret = 0;
	vm_log_debug("before xmpp_send_raw_d");
	if (serv->ssl_flag)
	{
		
		ret = ssl_write(&serv->ssl, (unsigned char*)xml_str, xml_len);
	
	}
	else
		ret = vm_tcp_write(serv->connect, xml_str, xml_len);
	write_log_debug(xml_str, xml_len);
	vm_log_debug("after xmpp_send_raw_d");
	if (ret < 0)
		return ret;
	return IKS_OK;
}